<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>新增文档 - 光年(Light Year Admin)后台管理系统模板</title>
<link rel="icon" href="${APP_PATH}/favicon.ico" type="image/ico">
<meta name="keywords" content="LightYear,光年,后台模板,后台管理系统,光年HTML模板">
<meta name="description" content="LightYear是一个基于Bootstrap v3.3.7的后台管理系统的HTML模板。">
<meta name="author" content="yinqi">

<jsp:include page="/commons.jsp"></jsp:include>
<!--标签插件-->
<link rel="stylesheet" href="public/js/jquery-tags-input/jquery.tagsinput.min.css">


</head>
  
<body>
<div class="lyear-layout-web">
  <div class="lyear-layout-container">
    <!--头部导航-->
    <jsp:include page="/head.jsp"></jsp:include>
    
       
     
    <!--End 左侧导航-->
   <jsp:include page="/menu.jsp"></jsp:include>
    <!--头部信息-->
    
    <!--End 头部信息-->
    
    <!--页面主要内容-->
    <main class="lyear-layout-content">
      
      <div class="container-fluid">
        
        <div class="row">
          <div class="col-lg-12">
            <div class="card">
              <div class="card-body">
                
                <form   method="post" class="row" id="classForm">
                  <div class="form-group col-md-12">
                     <label for="title">班级名称</label>
                    <input type="text" class="form-control" id="cname" name="cname" value="" placeholder="请输入班级名称" />
                    
                    </div>
                     
                    <div class="form-group col-md-12">
                      <label for="type"  >选择教师</label>
                      <select name="teacherid" class="form-control" id="teacher">
                    
                      </select>
                    </div>
                   <div class="form-group col-md-12">
                      <label for="type"  >选择班主任</label>
                      <select name="classmanagerid" class="form-control" id="classmanager">
                      
                      </select>
                    </div>
                  <div class="form-group col-md-12">
                      <label for="type"  >选择课程</label>
                      <select name="courseid" class="form-control" id="course">
                    
                      </select>
                    </div>
                    
                   <div class="form-group col-md-12">
                      <label for="type"  >选择教室</label>
                      <select name="roomid" class="form-control" id="room">
                   
                      </select>
                    </div>
                 
                  <div class="form-group col-md-12">
                    <button type="button" class="btn btn-primary ajax-post" target-form="add-form" id="btnSubmin">提交</button>
                    <button type="button" class="btn btn-default" onclick="javascript:history.back(-1);return false;">返 回</button>
                  </div>
                </form>
       
              </div>
            </div>
          </div>
          
        </div>
        
      </div>
      
    </main>
    <!--End 页面主要内容-->
  </div>
</div>




<!--标签插件-->
<script src="public/js/jquery-tags-input/jquery.tagsinput.min.js"></script>


<script>
       $(function(){
    	     $.ajax({
    	    	 url:"${APP_PATH}/class/list",
    	         type:"post",
    	         success:function(data){
    	        	 var tbodyContent="";
    	        	 var tbodyContent2="";
    	        	 var tbodyContent3="";
    	        	 var tbodyContent4="";
    	        
    	        	  if(data.msg){	
    	        		   
    	        		  $.each(data.teacherList,function(index,obj){
    	        			     
    	        	      tbodyContent+="<option  value="+obj.uid+">"+obj.user.uname+"</option>"
    	        			  
    	        		  });
    	        		  $("#teacher").html(tbodyContent);
    	        		  
    	        	 	  
    	                  $.each(data.classManagerList,function(index,obj){
    	                	
    	            	   tbodyContent2+= "<option  value="+obj.uid+">"+obj.user.uname+"</option>"   
    	        		  })
    	        		  $("#classmanager").html(tbodyContent2);
    	                  
    	               
    	                  $.each(data.courseList,function(index,obj){
       	            	   tbodyContent3+= "<option  value="+obj.courseid+">"+obj.cname+"</option>"   
       	        		  })
       	        		  $("#course").html(tbodyContent3);
    	                  
    	                  
    	                  $.each(data.roomList,function(index,obj){
    	                  tbodyContent4+= "<option value="+obj.rid+">"+obj.rname+"</option>"   
          	        	  })
          	        	 $("#room").html(tbodyContent4);
    	               
    	        	 } 
  
    	         }
    	     })  
    	     
    	     
    	     $("#btnSubmin").click(function(){
    	    	 $.ajax({
    	    		 url:"${APP_PATH}/class/addDo",
    	    		 typr:"post",
    	    		 data: $("#classForm").serialize(),
    	    		 success:function(data){
    	    			  if(data.msg){
    	    				  layer.msg("添加成功",{time:2000,icon:6,shift:4},function(){
    	    		    		  window.location.href="${APP_PATH}/class/supervisorIndex";
    	    		    	  })
    	    			  }else{
    	    				  layer.msg("添加失败",{time:2000,icon:6,shift:4},function(){
    	    		    	
    	    		    	  })
    	    			  }
    	    		 }
    	    	 })
    	     })
    	     
    	    
       })
</script>
</body>
</html>